package com.bms.web;

import java.util.ArrayList;
import java.util.List;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.web.servlet.ModelAndView;

import com.bms.Logic;
import com.bms.abstracts.RESTController;
import com.bms.domain.Event;

public class PerformanceListController extends RESTController {
	
	private Logic logic;
	
	public void setLogic(Logic logic) {
		this.logic = logic;
	}
	@Override
	protected ModelAndView doGet(HttpServletRequest request,
			HttpServletResponse response) {
List<Event> list = new ArrayList<Event>();
		
		String userid = request.getParameter("userid");
		String groups = request.getParameter("groups");
		
		if("".equals(userid) && !"".equals(groups)){
			list = logic.getPerformancfromGroup(groups);
		}
		if(!"".equals(userid) && "".equals(groups)){
			list = logic.getPerformancfromUserid(userid);
		}
		if("".equals(userid) && "".equals(groups)){
			list = logic.getPerformanclist();
		}
		return new ModelAndView("performancelist","list",list);
	}

	@Override
	protected ModelAndView doPost(HttpServletRequest request,
			HttpServletResponse response) {
		// TODO Auto-generated method stub
		return null;
	}

}
